使用多个数据集演示直方图(hist)函数 您所在的位置:网站首页 Excel画图教程 同轴重叠多个直方图 使用多个数据集演示直方图(hist)函数

使用多个数据集演示直方图(hist)函数

2024-07-11 18:46| 来源: 网络整理| 查看: 265

# 使用多个数据集演示直方图(hist)函数

绘制具有多个样本集的直方图并演示:

使用带有多个样本集的图例堆积图没有填充的步进曲线不同样本量的数据集

选择不同的存储量和大小会显著影响直方图的形状。Astropy文档有很多关于如何选择这些参数的部分: http://docs.astropy.org/en/stable/visualization/histogram.html

多个数据集演示直方图

import numpy as np import matplotlib.pyplot as plt np.random.seed(19680801) n_bins = 10 x = np.random.randn(1000, 3) fig, axes = plt.subplots(nrows=2, ncols=2) ax0, ax1, ax2, ax3 = axes.flatten() colors = ['red', 'tan', 'lime'] ax0.hist(x, n_bins, density=True, histtype='bar', color=colors, label=colors) ax0.legend(prop={'size': 10}) ax0.set_title('bars with legend') ax1.hist(x, n_bins, density=True, histtype='bar', stacked=True) ax1.set_title('stacked bar') ax2.hist(x, n_bins, histtype='step', stacked=True, fill=False) ax2.set_title('stack step (unfilled)') # Make a multiple-histogram of data-sets with different length. x_multi = [np.random.randn(n) for n in [10000, 5000, 2000]] ax3.hist(x_multi, n_bins, histtype='bar') ax3.set_title('different sample sizes') fig.tight_layout() plt.show() # 下载这个示例下载python源码: histogram_multihist.pyopen in new window下载Jupyter notebook: histogram_multihist.ipynbopen in new window


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有